package com.domdd.enums.upload.sos;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.poi.ss.usermodel.Row;

import java.util.Collection;
import java.util.Map;

/**
 * @Author David.Liu
 * @Date 2024-12-05 19:54
 **/
@Getter
@AllArgsConstructor
public enum InventoryNewEnum implements CommonUpload {
    outerId("商品编码", 0),
    barcode("规格条码", 1),
    goodsName("商品名称", 2),
    skuName("规格名称", 3),
    normalQuantity("良品库存", 4),
    substandardQuantity("残次品", 5),
    brokenQuantity("残品", 6),
    boxBrokenQuantity("盒损", 7),
    quantity("总库存", 8);


    private String columnName;

    private Integer index;

    private Boolean isNotNull = false;
    private Class valueType = String.class;
    private Integer maxLength;
    private String pattern;

    private String patternErrorMsg;

    InventoryNewEnum(String columnName, Integer index) {
        this.columnName = columnName;
        this.index = index;
    }

    InventoryNewEnum(String columnName, Integer index, Boolean isNotNull) {
        this.columnName = columnName;
        this.index = index;
        this.isNotNull = isNotNull;
    }

    InventoryNewEnum(String columnName, Integer index, Integer maxLength) {
        this.columnName = columnName;
        this.index = index;
        this.maxLength = maxLength;
    }

    InventoryNewEnum(String columnName, Integer index, String pattern) {
        this.columnName = columnName;
        this.index = index;
        this.pattern = pattern;
    }

    InventoryNewEnum(String columnName, Integer index, Boolean isNotNull, Class valueType) {
        this.columnName = columnName;
        this.index = index;
        this.isNotNull = isNotNull;
        this.valueType = valueType;
    }

    InventoryNewEnum(String columnName, Integer index, Boolean isNotNull, Integer maxLength) {
        this.columnName = columnName;
        this.index = index;
        this.isNotNull = isNotNull;
        this.maxLength = maxLength;
    }

    InventoryNewEnum(String columnName, Integer index, Boolean isNotNull, String pattern) {
        this.columnName = columnName;
        this.index = index;
        this.isNotNull = isNotNull;
        this.pattern = pattern;
    }

    InventoryNewEnum(String columnName, Integer index, Integer maxLength, String pattern) {
        this.columnName = columnName;
        this.index = index;
        this.maxLength = maxLength;
        this.pattern = pattern;
    }

    InventoryNewEnum(String columnName, Integer index, Boolean isNotNull, Integer maxLength, String pattern) {
        this.columnName = columnName;
        this.index = index;
        this.maxLength = maxLength;
        this.isNotNull = isNotNull;
        this.pattern = pattern;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public Class getValueType() {
        return valueType;
    }

    public void setValueType(Class valueType) {
        this.valueType = valueType;
    }

    public Integer getMaxLength() {
        return maxLength;
    }

    public void setMaxLength(Integer maxLength) {
        this.maxLength = maxLength;
    }

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    public Boolean getIsNotNull() {
        return isNotNull;
    }

    public void setIsNotNull(Boolean isNotNull) {
        this.isNotNull = isNotNull;
    }

    @Override
    public String getPatternErrorMsg() {
        return patternErrorMsg;
    }

    @Override
    public void setPatternErrorMsg(String patternErrorMsg) {
        this.patternErrorMsg = patternErrorMsg;
    }

    public static Map<String, Collection<String>> getErrorMsgByRow(Row r) {
        return CommonUpload.getErrorMsgByRow(InventoryNewEnum.values(), r);
    }
}
